package com.dbtest.dbutil;

import java.sql.*;

import javax.sql.DataSource;
 
import org.springframework.context.ApplicationContext;
 
import org.springframework.context.support.ClassPathXmlApplicationContext;
 
public class DBase {
 
  public static void main(String args[]) throws Exception{ 
 
    ApplicationContext ctx=new ClassPathXmlApplicationContext("dbtest.xml");  
 
   DataSource dataSource=ctx.getBean("dataSource",DataSource.class);
 
     String sql="select * from user_table";   
 
  Connection connection=dataSource.getConnection(); 
 
    Statement stm=connection.createStatement();   
 
  ResultSet rs=stm.executeQuery(sql); 
 
    while(rs.next())    
 
{       System.out.println("用户名为:"); 
 
     System.out.println(rs.getString(1)); 
 
    }                  
 
}
 
  
 
}
